
//import 'package:background_fetch/background_fetch.dart';
import 'package:elevator/pages/build_detail/build_detail_view.dart';
import 'package:elevator/pages/home/all/detail_new/detail_new_view.dart';
import 'package:elevator/pages/home/page_home_view.dart';
import 'package:elevator/pages/login/login_view.dart';
import 'package:elevator/pages/search/search_view.dart';
import 'package:elevator/pages/setting/setting_view.dart';
import 'package:elevator/pages/testing/testing_view.dart';
import 'package:elevator/storage/local_storage.dart';
import 'package:elevator/utils/mynotification.dart';
import 'package:elevator/utils/utls_tool.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'db/db_helper.dart';
import 'get/message.dart';


void main() async {
  // String localStr = await LocalStorage.get('local') ?? 'zh';//.setString('local', 'en');
  // Locale locale = Locale('zh', 'Hans');
  // switch(localStr) {
  //   case 'en':
  //     locale = Locale('en', 'US');
  //     break;
  // }

  //初始化本地通知
  WidgetsFlutterBinding.ensureInitialized();
  await MyNotification.init();

  DBHelper().initDb();

  Locale locale = await Messages.initHLocal();

  runApp(GetMaterialApp(
    locale: locale,
    translations: Messages(),
    // your translations
    // locale: Locale('en', 'US'), // translations will be displayed in that locale
    fallbackLocale: Get.deviceLocale,
    // specify the fallback locale in case an invalid locale is selected.
    // supportedLocales: const [Locale('zh', 'CH')],
    initialRoute: '/login',

    theme: ThemeData(
        primarySwatch: createMaterialColor(const Color(0xFF384A7C)),
        appBarTheme: const AppBarTheme(
            color: Color(0xFF384A7C),
          actionsIconTheme: IconThemeData(
            color: Colors.white
          ),
          iconTheme: IconThemeData(
            color: Colors.white
          )
        ),
        fontFamily: 'HanSans'),
    getPages: [
      GetPage(name: '/login', page: () => const LoginPage()),
      //const MyWebView()),
      GetPage(name: '/home', page: () => HomePage()),
      GetPage(name: '/search', page: () => SearchPage()),
      GetPage(name: '/setting', page: () => SettingPage()),
      GetPage(name: '/build_detail',page: () => BuildDetailPage()),
      GetPage(name: '/lift_detail',page: () => DetailNewPage()),
      GetPage(name: '/test', page: () => TestingPage()),
    ],
  ));
}

